<template>
    <div class="detail">
        <Header :detailNameData='detailNameData' />
      <ToBuy v-if="$store.state.isToBuy" :detailNameData='detailNameData'></ToBuy>
       <Footer v-else class="footer" />
    </div>
</template>

<script>
import ToBuy from '@/components/detail_ja/Detail_buy.vue'
import Header from '@/components/detail_ja/Detail_head.vue';

import Footer from "@/components/detail_ja/Detail_footer.vue";
import {  GoodsApi} from "@/request/api";
export default {
    data () {
        return {
            detailNameData:[],
           goodsId:null
 
        }
    },
    components:{
        Header,
       ToBuy,
        Footer

    },
    mounted(){
        // 查询detail
        // const {goodsId}=this.$route.params
        // console.log(goodsId);
         
        // this.HomeShowGoodsApi(goodsId)
    },
    created(){
        const {goodsName}=this.$route.params
        GoodsApi({
           goodsName:goodsName
           
            }).then(res=>{
                let arr=res.data.data
                console.log(arr);
                console.log(goodsId);
                arr.filter(item=>{
                    if(item.goodsName==goodsName){
                        
                        this.detailNameData=item
                        console.log(this.detailNameData);
                    }
                    
                    return  this.detailNameData
                   
                })
                

            
        })
      

    },
    methods:{
        // 查询商品详情
        
    }

}
</script>
 
<style lang = "less" scoped>
    .detail{
        position: relative;
        .footer{
            position:fixed;
            bottom: 0;
            left: 0;
            z-index: 9;
        }
        
    }
</style>